package com.example.video_open;


import android.app.Activity;
import android.media.MediaPlayer;
import android.net.Uri;

import com.example.video_open.ctr.MainController;
import com.example.video_open.widget.FullScreenVideoView;
import com.rq.base.net.RequestType;
import com.rq.base.ui.BaseController;
import com.rq.base.ui.impl.WelcomeImpl;
import com.rq.base.util.LOG;

public class WelcomePage implements WelcomeImpl {

    String updatePath = "https://****.apk";

    @Override
    public int getLayoutId() {
        return R.layout.act_welcome;
    }

    @Override
    public long getAutoSkipTime() {
        return 3000;
    }

    @Override
    public void skip(final BaseController view) {
        // TODO: 2020-10-22 根据情况跳转主页或者登录页
        view.skip(MainController.class);
    }

    @Override
    public void init(final BaseController view) {
        final FullScreenVideoView fv = view.getView(R.id.fv_bg);
        // TODO: 2023/2/17 下面资源随便放一个MP4文件即可
        Uri uri = Uri.parse("android.resource://" + view.getContext().getPackageName() + "/" + R.raw.ic_welcome);
        fv.setVideoURI(uri);
        fv.start();
        fv.setOnPreparedListener(mp -> {
            mp.setLooping(false);
            mp.start();
        });
        //模拟请求回调,实际会调用到本类 isSkipData 进行判断
        view.runOnUiThread(() -> view.onResponseSucceed(null, null), 2000);
    }

    @Override
    public boolean isSkipData(BaseController controller, RequestType type, Object data) {
        LOG.e("WelcomePage", "52:");
        return true;
    }

    @Override
    public void clickDownload(Activity context, String updatePath, String s) {
        LOG.e("WelcomePage", "54:调用下载接口");
    }

    @Override
    public String getUpdatePath() {
        return updatePath;
    }

    @Override
    public String getNetVersionName() {
        return "test2_8";
    }

    @Override
    public String getVersionDescribe() {
        return "测试描述";
    }

    @Override
    public boolean isCancelAble() {
        return true;
    }
}
